﻿using System;
using NUnit.Framework;

namespace noug.tdd.tests {

    [TestFixture]
    public class When_validating_emails {
        EmailValidator _emailValdator;
        [SetUp] public void SetUp() {
            _emailValdator = new EmailValidator(); }
        [Test] public void regular_email_should_be_valid() {
            Assert.IsTrue(_emailValdator.IsValid("a@b.com"));}
        [Test] public void email_to_exotic_domain_should_be_valid() {
            Assert.IsTrue(_emailValdator.IsValid("a@b.co.in")); }
        [Test] public void email_with_full_user_name_should_be_valid() {
            Assert.IsTrue(_emailValdator.IsValid("Mr A <a@b.com>")); }
        [Test] public void email_to_incomplete_domain_name_should_be_invalid() {
            Assert.IsFalse(_emailValdator.IsValid("a@b")); }
        [Test] public void improperly_brackated_email_should_be_invalid() {
            Assert.IsFalse(_emailValdator.IsValid("Mr A> a@b")); }
        [Test] public void email_to_invalid_domain_name_should_be_invalid() {
            Assert.IsFalse(_emailValdator.IsValid("a@b.com/blah")); }
        [Test] public void email_with_space_should_be_invalid() {
            Assert.IsFalse(_emailValdator.IsValid("a @b")); }
        [Test] public void empty_email_should_be_invalid() {
            Assert.IsFalse(_emailValdator.IsValid("")); }
        [Test] public void null_email_should_be_invalid() {
            Assert.IsFalse(_emailValdator.IsValid(null)); }
    }
}
